package com.example.demo.com.java8.annotation;

import org.junit.Test;

import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Method;

/**
 * @author chengfei5
 * @date 2018/8/22
 */
public class TestAnnotation {

    @Test
    public void test() throws Exception {
        Class<TestAnnotation> testAnnotationClass = TestAnnotation.class;
        Method show = testAnnotationClass.getMethod("show");
        MyAnnotation[] annotationsByType = show.getAnnotationsByType(MyAnnotation.class);

        for(MyAnnotation myAnnotation:annotationsByType){
            System.out.println(myAnnotation.value());
        }
    }
    @MyAnnotation("hello")
    @MyAnnotation("world")
    public void show(){

    }
}
